<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="callArkTS()">Click Me!</button>
<p id="demo"></p>
<p id="showArr"></p>
<p id="showObj"></p>
<p id="hello1"></p>
<p id="hello2"></p>
<p id="showPromise"></p>
<p id="receivePromise"></p>
<script>
    // 写法一
    class Student {
        constructor(nameList) {
            this.methodNameListForJsProxy = nameList;
        }
        hello(param) {
            document.getElementById("hello1").innerHTML = "方式1：" + param;
        }
    }
    var st = new Student(["hello"])
    // 写法2
    //创建一个构造器，构造函数首字母大写
    function Obj1(){
        this.methodNameListForJsProxy=["hello"];
        this.hello=function(param){
            document.getElementById("hello2").innerHTML = "方式2：" + param;
        };
    }
    //利用构造器，通过new关键字生成对象
    var st1 = new Obj1();
    function callArkTS() {
        let str = testObjName.test();
        document.getElementById("demo").innerHTML = str;
        console.info('ArkTS Hello World! :' + str);
        let str2 = testObjName.toString();
        console.info('ArkTS toString() :' + str2);
        let arr = testObjName.deliverArray();
        document.getElementById("showArr").innerHTML = arr;
        let obj = testObjName.deliverObject();
        let obj_str = "姓名:" + obj.name + "，年龄:" + obj.age;
        document.getElementById("showObj").innerHTML = obj_str;
        testObjName.callH5Func(function(param){testObjName.bridgeMessage(param)});
        testObjName.sayHello(st, st1);
        testObjName.callObjFunc().testOther("前端页面调用应用侧Object里的Function");
        testObjName.callPromise().then((param) => {
            let msg = "Promise成功：" + param;
            document.getElementById("showPromise").innerHTML = msg;
        }).catch((param) => {
            let msg = "Promise失败：" + param;
            document.getElementById("showPromise").innerHTML = msg;
        })
        let funPromise;
        var promise = new Promise(function(resolve, reject){
            funPromise=(param) => {resolve(param)};
        });
        testObjName.receivePromise(funPromise);
        promise.then((param) => {
            let msg = "Promise成功：" + param;
            testObjName.bridgeMessage(msg)
            document.getElementById("receivePromise").innerHTML = msg;
        })
    }
</script>
</body>
</html>